/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package databaseconnectivityprogram;
import java.sql.*;
/**
 *
 * @author harshi
 */
public class DatabaseConnectivityProgram {
    

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Connection con=null;
        Statement stmt=null;
        ResultSet rs=null;
        try{
            
            con=DriverManager.getConnection("jdbc:mysql://localhost/harshi","root","harshi");  
            stmt=con.createStatement();
            rs=stmt.executeQuery("select * from student");
                while(rs.next()){
                    System.out.println(rs.getInt("rollno")+"---"+rs.getString("name"));
                }
            stmt.close();
            rs.close();            
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
